// 分页逻辑
document.addEventListener('DOMContentLoaded', function() {
    const itemsPerPage = 5; // 每页显示的项目数量
    const items = document.querySelectorAll('.item'); // 假设每个项目都有一个类名为 'item'
    const paginationContainer = document.getElementById('pagination');
    let currentPage = 1;

    // 初始化分页
    function initPagination() {
        const totalPages = Math.ceil(items.length / itemsPerPage);
        paginationContainer.innerHTML = '';

        for (let i = 1; i <= totalPages; i++) {
            const pageButton = document.createElement('button');
            pageButton.textContent = i;
            pageButton.addEventListener('click', () => {
                currentPage = i;
                showPage(currentPage);
            });
            paginationContainer.appendChild(pageButton);
        }
    }

    // 显示指定页的内容
    function showPage(page) {
        const startIndex = (page - 1) * itemsPerPage;
        const endIndex = startIndex + itemsPerPage;

        items.forEach((item, index) => {
            if (index >= startIndex && index < endIndex) {
                item.style.display = 'block';
            } else {
                item.style.display = 'none';
            }
        });
    }

    // 初始化显示第一页
    initPagination();
    showPage(currentPage);
});